<template>
  <el-row class="tables">
    <!-- 表格 头部 -->
    <el-row class="tableTh">
      <el-col :span="3">
        <span>任务类型</span>
      </el-col>
      <el-col :span="4">
        <span>物料类别</span>
      </el-col>
      <el-col :span="4">
        <span>物料名称</span>
      </el-col>
      <el-col :span="3">
        <span>采购数量</span>
      </el-col>
      <el-col :span="4">
        <span>采购时间</span>
      </el-col>
      <el-col :span="3">
        <span>采购单号</span>
      </el-col>
      <el-col :span="3">
        <span>采购人</span>
      </el-col>
    </el-row>
    <!-- 表格行 -->
    <div v-if="tableData.length > 0" class="showDiv">
      <el-row v-for="(item,index) in tableData" :key="item.id" :class="{ 'row-striped': index % 2 === 1 }" class="tableTd">
        <el-col :span="3">
          <span>{{ item.type }}</span>
        </el-col>
        <el-col :span="4">
          <span>{{ item.classifyName }}</span>
        </el-col>
        <el-col :span="4">
          <span>{{ item.materialName }}</span>
        </el-col>
        <el-col :span="3">
          <span>{{ item.num }}</span>
        </el-col>
        <el-col :span="4">
          <span>{{ item.purchaseDate}}</span>
        </el-col>
        <el-col :span="3">
          <span>{{ item.purchaseNo }}</span>
        </el-col>
        <el-col :span="3">
          <span>{{ item.userName }}</span>
        </el-col>
      </el-row>
    </div>
    <div v-else class="kong">暂无数据</div>
  </el-row>
</template>
<script>
export default {
  props: {
    tableData: {
      type: Array,
      default: []
    }
  },
  data() {
    return {}
  },
  watch: {},
  mounted() {},
  methods: {}
}
</script>
<style lang='scss' scoped>
.row-striped {
  background-color: #305483; /* 背景色可以根据需要自定义 */
}
.tables {
  height: 50%;
  color: #fff;
  .showDiv {
    height: 75%;
  }
  .tableTh,
  .tableTd {
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    .el-col {
      text-overflow: ellipsis; /*让截断的文字显示为点点。还有一个值是clip意截断不显示点点*/
      white-space: nowrap; /*让文字不换行*/
      overflow: hidden; /*超出要隐藏*/
    }
  }
  .tableTh {
    width: 100%;
    height: 25%;
    // font-weight: bold;
    font-size: 12px;
    background: #396ba2;
  }
  .tableTd {
    height: 25%;
    font-size: 12px;
    // font-weight: bold;
  }
  .kong {
    height: calc(100% - 65px);
    // background: url(../../../../assets/images/zwsj.png) no-repeat center;
    background-size: 50% auto;
    display: flex;
    align-items: center;
    justify-content: center; /*定义body的里的元素水平居中*/
    color: #fff;
    font-size: 0.8vw;
  }
}
</style>
